Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Convert CumeDist to UDWF #13051

Merged
merged 8 commits into from
Oct 23, 2024
Merged

Conversation

jonathanc-n
Copy link
Contributor

Which issue does this PR close?

Closes #12695 .

Rationale for this change

What changes are included in this PR?

Converted CumeDist to user defined window function.

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Physical Expressions sqllogictest SQL Logic Tests (.slt) proto Related to proto crate labels Oct 21, 2024
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 21, 2024
CUME_DIST() OVER(ORDER BY c9) as cd1,
CUME_DIST() OVER(ORDER BY c9 ROWS BETWEEN 10 PRECEDING and 1 FOLLOWING) as cd2
cume_dist() OVER(ORDER BY c9) as cd1,
cume_dist() OVER(ORDER BY c9 ROWS BETWEEN 10 PRECEDING and 1 FOLLOWING) as cd2
Copy link
Member

@findepi findepi Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is consistent with conversion of other user-defined window functions.

Copy link
Contributor

@timsaucer timsaucer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jcsherin
Copy link
Contributor

@jonathanc-n A roundtrip test for cume_dist() expression API can be added here:

row_number(),
rank(),
dense_rank(),
percent_rank(),
lead(col("b"), None, None),
lead(col("b"), Some(2), None),
lead(col("b"), Some(2), Some(ScalarValue::from(100))),
lag(col("b"), None, None),
lag(col("b"), Some(2), None),
lag(col("b"), Some(2), Some(ScalarValue::from(100))),

@@ -940,6 +940,7 @@ async fn roundtrip_expr_api() -> Result<()> {
vec![lit(1), lit(2), lit(3)],
vec![lit(10), lit(20), lit(30)],
),
cume_dist(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

- [dense_rank](#dense_rank)
- [percent_rank](#percent_rank)
- [rank](#rank)
- [row_number](#row_number)

### `cume_dist`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@alamb
Copy link
Contributor

alamb commented Oct 22, 2024

Love it -- thank you @jonathanc-n and @findepi @timsaucer and @jcsherin for the reviews

@alamb
Copy link
Contributor

alamb commented Oct 23, 2024

🚀

@alamb alamb merged commit a4e6b07 into apache:main Oct 23, 2024
25 checks passed
@jonathanc-n jonathanc-n deleted the convert-cumedist-to-udwf branch November 1, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation logical-expr Logical plan and expressions physical-expr Physical Expressions proto Related to proto crate sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert BuiltInWindowFunction::CumeDist to a user defined window function
5 participants